package com.yanfan.modbus.frame;


import com.yanfan.modbus.exception.ModbusTransportException;
import com.yanfan.modbus.frame.abs.ModbusResponse;
import io.netty.buffer.ByteBuf;

/**
 * @author oliver foo
 * @description
 * @date 2022/3/15 17:14
 */
public class ExceptionResponse extends ModbusResponse {
    private final byte functionCode;


    public ExceptionResponse(int slaveId, byte functionCode, byte exceptionCode) throws ModbusTransportException {
        super(slaveId);
        this.functionCode = functionCode;
        setException(exceptionCode);
    }


    @Override
    public byte getFunctionCode() {
        return functionCode;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    protected void readResponse(ByteBuf buf) {
        // no op
    }

    /**
     * {@inheritDoc}
     */
    @Override
    protected void writeResponse(ByteBuf buf) {
        // no op
    }
}
